/*
               File: dEnCla
        Description: DesEncripta Clave
             Author: GeneXus C# Generator version 8_0_0-201
       Generated on: 21 de Setiembre de 2010 17:41:25.69
       Program type: Callable routine
          Main DBMS: sqlserver
*/
namespace GeneXus.Programs {
   using System;
   using System.Collections;
   using GeneXus.Utils;
   using GeneXus.Resources;
   using GeneXus.Application;
   using GeneXus.Metadata;
   using com.genexus;
   using com.genexus.ui;
   using com.genexus.uifactory;
   using GeneXus.Windows;
   using GeneXus.Data;
   using GeneXus.Data.FAT;
   using GeneXus.Http;
   using GeneXus.Procedure;
   using System.Threading;
   using GeneXus.XML;
   using GeneXus.Encryption;
   using GeneXus.Http.Client;
   public class pdencla_wrapper : GXJWin
   {
      public pdencla_wrapper( int hnd ,
                              ModelContext jContext ) : base(hnd, jContext)
      {
      }

   }

   public class pdencla : GXWinProcedure
   {
      public pdencla( int hnd ,
                      ModelContext jContext ) : base(hnd, jContext)
      {
         IsMain = true;
         context = new GxContext();
         context.DataStores.Add(new GxDataStore( new GxSqlServer(),"Default"));
      }

      public pdencla( )
      {
         context = new GxContext();
         context.DataStores.Add(new GxDataStore( new GxSqlServer(),"Default"));
         IsMain = true;
      }

      public pdencla( IGxContext context ) : base(-1, null)
      {
         this.context = context;
         IsMain = false;
      }

      public pdencla( IGxContext context ,
                      int hnd ,
                      ModelContext jContext ) : base(hnd, jContext)
      {
         this.context = context;
         IsMain = false;
      }

      public void execute( String aP0_Usucla ,
                           String aP1_Usuaux ,
                           out String aP2_Usuclaenc )
      {
         this.AV8Usucla = aP0_Usucla;
         this.AV9Usuaux = aP1_Usuaux;
         this.AV10Usucla = "" ;
         initialize();
         executePrivate();
         aP2_Usuclaenc=this.AV10Usucla;
      }

      public void executeSubmit( String aP0_Usucla ,
                                 String aP1_Usuaux ,
                                 out String aP2_Usuclaenc )
      {
         pdencla objpdencla;
         objpdencla = new pdencla();
         objpdencla.AV8Usucla = aP0_Usucla;
         objpdencla.AV9Usuaux = aP1_Usuaux;
         objpdencla.AV10Usucla = "" ;
         objpdencla.initialize();
         Thread execThread;
         execThread = new Thread(new ThreadStart( objpdencla.executePrivate ));
         execThread.Start();
         aP2_Usuclaenc=this.AV10Usucla;
      }

      void executePrivate( )
      {
         /* GeneXus formulas */
         /* Output device settings */
         AV11Clave = StringUtil.Trim( StringUtil.Substring( AV9Usuaux, 1, 10)) + StringUtil.Trim( StringUtil.Substring( AV9Usuaux, 12, 10)) + StringUtil.Trim( StringUtil.Substring( AV9Usuaux, 23, 12)) ;
         AV10Usucla = Crypto.Encrypt64( AV8Usucla, AV11Clave) ;
         AV10Usucla = StringUtil.Substring( AV10Usucla, 1, 10) ;
         this.cleanup();
      }

      public override int getOutputType( )
      {
         return GxReportUtils.OUTPUT_RVIEWER_DLL ;
      }

      protected void cleanup( )
      {
         this.AV10Usucla = AV10Usucla;
         if ( IsMain )
         {
            context.CloseConnections() ;
         }
      }

      public override void initialize( )
      {
         AV11Clave = "" ;
         /* GeneXus formulas. */
         Gx_err = 0 ;
      }

      private short Gx_err ;
      private String AV8Usucla ;
      private String AV9Usuaux ;
      private String AV11Clave ;
      private String AV10Usucla ;
      private String aP2_Usuclaenc ;
   }

}
